cbuffer cbPerObject
{
	float4x4 WorldViewProjection;	
	float4x4 WorldView;
}
cbuffer cbGlobal
{
	float2 normalTextureSize;
}

SamplerState NormalSampler
{
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Clamp;
    AddressV = Clamp;
};
Texture2D normalTexture;

struct App2VS
{
	float4 pos : POSITION;
	float3 normal : NORMAL;
	float4 col : COLOR;
	float2 uv : TEXCOORD0;
};

struct VS2PS
{
	float4 pos : SV_Position;
};
struct PS2GPU
{
	float4 value : SV_Target0;
};
void vs(App2VS IN, out VS2PS OUT)
{
	OUT.pos = mul(IN.pos, WorldViewProjection);
}

void ps(VS2PS IN, out PS2GPU OUT)
{
	float2 uv = IN.pos / normalTextureSize;
	OUT.value = float4(normalTexture.Sample(NormalSampler, uv).rgb, 1);
}

technique10 Render
{
	pass P0
	{
		SetGeometryShader( 0 );
		SetVertexShader( CompileShader( vs_4_0, vs() ) );
		SetPixelShader( CompileShader( ps_4_0, ps() ) );
	}
}